Add paper's EntityFertilizeEgg event#8231
Add paper's EntityFertilizeEgg event#8231CJH3139 wants to merge 15 commits intoSkriptLang:dev/featurefrom
Conversation
Also change for: - block fertilize event bone[ ]meal alias - ExprBreedingFamily tweaks so that it also accepts the FertilizeEgg event
|
oh and on the error message screenshot, changed the first error message line to |
| "\tif event-entity is a frog:", | ||
| "\t\tsend \"A frog just became pregnant!\"" | ||
| ) | ||
| .since("2.14"); |
There was a problem hiding this comment.
| .since("2.14"); | |
| .since("INSERT VERSION"); |
| .since("2.14"); | ||
|
|
||
| EventValues.registerEventValue(EntityFertilizeEggEvent.class, Entity.class, event -> { | ||
| assert false; |
There was a problem hiding this comment.
this will error on all servers with the ea flag, so probably best to remove it
| if (!getParser().isCurrentEvent(EntityBreedEvent.class) && !getParser().isCurrentEvent(EntityFertilizeEggEvent.class)) { | ||
| Skript.error("The 'breeding family' expression can only be used in an breed or fertilize egg event."); | ||
| return false; | ||
| } |
| public class EvtFertilizeEgg extends SkriptEvent { | ||
| static { |
There was a problem hiding this comment.
| public class EvtFertilizeEgg extends SkriptEvent { | |
| static { | |
| public class EvtFertilizeEgg extends SkriptEvent { | |
| static { |
| .examples( | ||
| "on fertilizing egg of turtles:", | ||
| "\tsend \"A turtle just fertilized an egg!\"", | ||
| "on fertilizing egg:", | ||
| "\tif event-entity is a frog:", | ||
| "\t\tsend \"A frog just became pregnant!\"" | ||
| ) |
There was a problem hiding this comment.
| .examples( | |
| "on fertilizing egg of turtles:", | |
| "\tsend \"A turtle just fertilized an egg!\"", | |
| "on fertilizing egg:", | |
| "\tif event-entity is a frog:", | |
| "\t\tsend \"A frog just became pregnant!\"" | |
| ) | |
| .examples(""" | |
| on fertilizing egg of turtles: | |
| send "A turtle just fertilized an egg!" | |
| on fertilizing egg: | |
| if event-entity is a frog: | |
| send "A frog just became pregnant!" | |
| """) |
Also, use broadcast instead of send since that's invalid as there's no default player to send a message to.
|
|
||
| @Override | ||
| public String toString(@Nullable Event event, boolean debug) { | ||
| return "on fertilizing egg" + (entitiesLiteral == null ? "" : " of " + entitiesLiteral); |
There was a problem hiding this comment.
| return "on fertilizing egg" + (entitiesLiteral == null ? "" : " of " + entitiesLiteral); | |
| return "on fertilizing egg" + (entitiesLiteral == null ? "" : " of " + entitiesLiteral.toString(event, debug)); |
|
Do you intend to continue working on this? |
Removed all the deprecated things (EventValue & registerEvent) and now uses EventValueRegistry & SyntaxRegistry
Co-authored-by: SirSmurfy2 <82696841+Absolutionism@users.noreply.github.com>
| @Test | ||
| public void test() { | ||
| Bukkit.getPluginManager().callEvent( | ||
| new EntityFertilizeEggEvent(mother, father, null, null, 0)); |
There was a problem hiding this comment.
Should add in a player, itemstack, and arbitrary number for experience to make sure the event values work in the sk file
Co-authored-by: SirSmurfy2 <82696841+Absolutionism@users.noreply.github.com>
…/EvtFertilizeEggTest.java Co-authored-by: SirSmurfy2 <82696841+Absolutionism@users.noreply.github.com>
…in the skript file
| import org.skriptlang.skript.bukkit.registration.BukkitSyntaxInfos; | ||
| import org.skriptlang.skript.registration.SyntaxRegistry; | ||
|
|
||
| public class EvtFertilizeEgg extends SkriptEvent { |
There was a problem hiding this comment.
This should be moved to org.skriptlang paackage
| BukkitSyntaxInfos.Event.KEY, | ||
| BukkitSyntaxInfos.Event.builder(EvtFertilizeEgg.class, "Entity Fertilize") | ||
| .addEvent(EntityFertilizeEggEvent.class) | ||
| .addPatterns("[entity] fertiliz(e|ing) [an] egg [of %-entitytypes%]") |
There was a problem hiding this comment.
I think [%-entitytypes%] egg fertiliz(e|ation) could be a good pattern.
on egg fertilize
on turtle egg fertilization
Problem
#7819
Solution
[block] fertilize->"[block] (fertilize|bone[ ]meal)")childfrom ExprBreedingFamily (Still in blockstate or not an entity at all in some case)Testing Completed
Tested both with a script and manually

Supporting Information
Completes: #7819
Related: none